package com.graduationdesign.zengyan.graduationdesignapp.ui.activities.widgets;

import android.support.annotation.IdRes;
import android.support.v4.widget.NestedScrollView;
import android.view.View;

import com.graduationdesign.zengyan.graduationdesignapp.ui.activities.nav.NavActiviity;
import com.graduationdesign.zengyan.graduationdesignapp.ui.base.BaseFragment;
import com.orhanobut.logger.Logger;

/**
 * Created by ZengYan on 2018/4/22.
 *
 * @desc :
 */
public abstract class NavTabFragment extends BaseFragment{



    @Override
    protected void initView(View view) {
        Logger.i(TAG+": initView");
        NestedScrollView nested_content = (NestedScrollView) view.findViewById(provideNestedViewId());
        NavActiviity activiity = (NavActiviity) getActivity();
        nested_content.setOnScrollChangeListener((NestedScrollView.OnScrollChangeListener) (v, scrollX, scrollY, oldScrollX, oldScrollY) -> {
            if (scrollY < oldScrollY) { // up
                activiity.animateNavigation(false);
            }
            if (scrollY > oldScrollY) { // down
                activiity.animateNavigation(true);
            }
        });
    }

    protected abstract @IdRes int provideNestedViewId();


}
